import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('hello'),
        ),
        body: const Column(
          children: [MyApp(), MyButton(), MyText()],
        ),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      // Container 类似 div
      child: Container(
        alignment: Alignment.center,
        margin: const EdgeInsets.fromLTRB(0, 40, 0, 0),
        // transform: Matrix4.translationValues(50, 0, 0),
        // transform: Matrix4.rotationZ(0.2),
        width: 200,
        height: 200,
        // 装饰
        decoration: BoxDecoration(
          color: Colors.red,
          border: Border.all(color: Colors.yellow, width: 10),
          borderRadius: BorderRadius.circular(30),
          boxShadow: const [BoxShadow(color: Colors.black, blurRadius: 10.0)],
          gradient: const LinearGradient(colors: [Colors.red, Colors.amber]),
        ),
        child: const Text(
          '你好',
          style: TextStyle(color: Colors.white, fontSize: 20),
        ),
      ),
    );
  }
}

class MyButton extends StatelessWidget {
  const MyButton({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      width: 200,
      height: 40,
      margin: const EdgeInsets.all(10),
      // padding: const EdgeInsets.fromLTRB(40, 0, 0, 0),
      decoration: BoxDecoration(
        color: Colors.blue,
        borderRadius: BorderRadius.circular(10),
      ),
      child: const Text(
        "按钮",
        style: TextStyle(color: Colors.white, fontSize: 20),
      ),
    );
  }
}

class MyText extends StatelessWidget {
  const MyText({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 200,
      height: 200,
      margin: const EdgeInsets.fromLTRB(0, 40, 0, 0),
      decoration: const BoxDecoration(color: Colors.yellow),
      child:  const Text(
        '你好Flutter你好Flutter你好Flutter你好Flutter你好Flutter你好Flutter',
        textAlign: TextAlign.left, // 文本对齐方式
        maxLines: 1, // 最大显示行数
        overflow: TextOverflow.ellipsis, // 超出省略
        style: TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Colors.red,
            fontStyle: FontStyle.italic,
            letterSpacing: 10,
            decoration: TextDecoration.lineThrough,
            decorationColor: Colors.black),
      ),
    );
  }
}
